capture clear all
set more off
set mem 2000m
set matsize 11000
set maxvar 10000



cd "Replication data and files\"	


use "Uncomtrade data for replication", clear


gen combined_ntrgap=combined*ntr_gap

foreach x of varlist us_post_ntrgap post_ntrgap eu_post_ntrgap japan_post_ntrgap korea_post_ntrgap combined_post_ntrgap {
egen `x'_std=std(`x')
}

keep year exports eu japan korea combined_ntrgap ntr_gap taiwan us us_post_ntrgap_std cy_fixed* py_fixed* product_year country_product partnercode combined* ntr_rate japan_tariff eu_tariff korea_tariff taiwan_tariff hs4

gen ntr_rate_sq=ntr_rate^2
foreach x in japan eu korea taiwan {
gen `x'_tariff_sq=`x'_tariff^2
}


gen log_exports=log(exports)
qui tab partnercode, gen(partnerfixed)

keep if eu==1 | japan==1 | korea==1 | taiwan==1 | us==1

*areg log_exports us_post_ntrgap combined_post_ntrgap, cl(partnercode) a(product_year)


areg log_exports us_post_ntrgap combined_post_ntrgap ntr_rate japan_tariff eu_tariff korea_tariff taiwan_tariff, cl(partnercode) a(product_year)
est2vec uncomtrade, vars(us_post_ntrgap combined_post_ntrgap) na(Col1)
areg log_exports us_post_ntrgap combined_post_ntrgap ntr_rate japan_tariff eu_tariff korea_tariff taiwan_tariff, cl(hs4) a(product_year)
est2vec uncomtrade, addto(uncomtrade) na(Col2)
areg log_exports us_post_ntrgap combined_post_ntrgap ntr_rate japan_tariff eu_tariff korea_tariff taiwan_tariff *_sq, cl(partnercode) a(product_year)
est2vec uncomtrade, addto(uncomtrade) na(Col3)
areg log_exports us_post_ntrgap combined_post_ntrgap ntr_rate japan_tariff eu_tariff korea_tariff taiwan_tariff *_sq, cl(hs4) a(product_year)
est2vec uncomtrade, addto(uncomtrade) na(Col4)
est2tex uncomtrade, replace preserve path("Output") mark(stars) levels(90 95 99) fancy collabels("Exports")
